🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / datastore / src / commonMain / kotlin / org / meshtastic / core / datastore / ModuleConfigDataSource.kt
Displaying Raw • Download
core/datastore/src/commonMain/kotlin/org/meshtastic/core/datastore/ModuleConfigDataSource.kt bf929c20f274232e0eb8ddc19b2dc82403e99e5b (bf929c20) Text, 3.60 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.datastore
Tff7b72import T7ee787androidx.datastore.core.DataStore
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.catch
Tff7b72import T7ee787okio.IOException
Tff7b72import T7ee787org.koin.core.annotation.Named
Tff7b72import T7ee787org.koin.core.annotation.Single
Tff7b72import T7ee787org.meshtastic.proto.LocalModuleConfig
Tff7b72import T7ee787org.meshtastic.proto.ModuleConfig
T8b949e/** Class that handles saving and retrieving [LocalModuleConfig] data. */
Tf0883e@Single
Tff7b72class T56d364ModuleConfigDataSourceTb4b4b4(
Tf0883e@NamedTb4b4b4(Ta5d6ff"Ta5d6ffCoreModuleConfigDataStoreTa5d6ff"Tb4b4b4) Tff7b72private Tff7b72val Te6edf3moduleConfigStoreTb4b4b4: Te6edf3DataStoreTff7b72<Te6edf3LocalModuleConfigTff7b72>Tb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3moduleConfigFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3LocalModuleConfigTff7b72> Tff7b72=
Te6edf3moduleConfigStoreTb4b4b4.Te6edf3dataTb4b4b4.Te6edf3catch Tb4b4b4{ Te6edf3exception Tff7b72-Tff7b72>
T8b949e// dataStore.data throws an IOException when an error is encountered when reading data
Tff7b72if Tb4b4b4(Te6edf3exception Tff7b72is Te6edf3IOExceptionTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3e Tb4b4b4{ Ta5d6ff"Ta5d6ffError reading LocalModuleConfig settings: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff" Tb4b4b4}
Te6edf3emitTb4b4b4(Te6edf3LocalModuleConfigTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Tff7b72throw Te6edf3exception
Tb4b4b4}
Tb4b4b4}
Tff7b72suspend Tff7b72fun Td2a8ffclearLocalModuleConfigTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3moduleConfigStoreTb4b4b4.Te6edf3updateData Tb4b4b4{ Te6edf3LocalModuleConfigTb4b4b4(Tb4b4b4) Tb4b4b4}
Tb4b4b4}
T8b949e/** Updates [LocalModuleConfig] from each [ModuleConfig] oneOf. */
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffCyclomaticComplexMethodTa5d6ff"Tb4b4b4)
Tff7b72suspend Tff7b72fun Td2a8ffsetLocalModuleConfigTb4b4b4(Te6edf3configTb4b4b4: Te6edf3ModuleConfigTb4b4b4) Tff7b72= Te6edf3moduleConfigStoreTb4b4b4.Te6edf3updateData Tb4b4b4{ Te6edf3current Tff7b72-Tff7b72>
Tff7b72when Tb4b4b4{
Te6edf3configTb4b4b4.Te6edf3mqtt Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3mqtt Tff7b72= Te6edf3configTb4b4b4.Te6edf3mqttTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3serial Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3serial Tff7b72= Te6edf3configTb4b4b4.Te6edf3serialTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3external_notification Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72>
Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3external_notification Tff7b72= Te6edf3configTb4b4b4.Te6edf3external_notificationTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3store_forward Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3store_forward Tff7b72= Te6edf3configTb4b4b4.Te6edf3store_forwardTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3range_test Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3range_test Tff7b72= Te6edf3configTb4b4b4.Te6edf3range_testTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3telemetry Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3telemetry Tff7b72= Te6edf3configTb4b4b4.Te6edf3telemetryTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3canned_message Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3canned_message Tff7b72= Te6edf3configTb4b4b4.Te6edf3canned_messageTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3audio Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3audio Tff7b72= Te6edf3configTb4b4b4.Te6edf3audioTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3remote_hardware Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3remote_hardware Tff7b72= Te6edf3configTb4b4b4.Te6edf3remote_hardwareTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3neighbor_info Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3neighbor_info Tff7b72= Te6edf3configTb4b4b4.Te6edf3neighbor_infoTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3ambient_lighting Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3ambient_lighting Tff7b72= Te6edf3configTb4b4b4.Te6edf3ambient_lightingTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3detection_sensor Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3detection_sensor Tff7b72= Te6edf3configTb4b4b4.Te6edf3detection_sensorTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3paxcounter Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3paxcounter Tff7b72= Te6edf3configTb4b4b4.Te6edf3paxcounterTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3statusmessage Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3statusmessage Tff7b72= Te6edf3configTb4b4b4.Te6edf3statusmessageTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3tak Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3tak Tff7b72= Te6edf3configTb4b4b4.Te6edf3takTb4b4b4)
Te6edf3configTb4b4b4.Te6edf3mesh_beacon Tff7b72!Tff7b72= Tff7b72null Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3copyTb4b4b4(Te6edf3mesh_beacon Tff7b72= Te6edf3configTb4b4b4.Te6edf3mesh_beaconTb4b4b4)
Tff7b72else Tff7b72-Tff7b72> Te6edf3current
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.07s